<?php $_SESSION['History']['Pre']= array('controller'=>'bulletins', 'action'=>'index')?>
<?php $paginator->options(array('url' => $this->passedArgs));?>
<table>
  <tr>
  	<?php if($session->read('Auth.User')!=array()):?>
    <td width="150px">
    <?php echo $html->link('發表文章', 
    	array(
    		'controller'=>'posts',
    		'action'=>'add'
    	)
    )?>
    </td>
    <?php else:?>
    <td width="300px">
    	<?php echo $html->link('登入', 
    		array(
    			'controller'=>'users',
    			'action'=>'login'
    		)
    	)?>後即可發表文章
    </td>
    <?php endif?>
    <td></td>
  </tr>
</table>

<table>
  <tr>
    <th width="60%">標題</th>
    <th>作者</th>
    <th><?php echo $paginator->sort('時間', 'Post.ptime')?></th>
    <th>回覆</th>
    <th>最後發表</th>
    <th><?php echo $paginator->sort('回覆時間', 'Post.repost_ptime')?></th>
  </tr>
  <?php foreach($data as $key=>$post):?>
  <tr>
  	<td style="font-size: 10px"><?php echo $html->link($post['Post']['title'], 
  		array(
  			'controller'=>'bulletins',
  			'action'=>'view',
  			$post['Post']['id']
  		)
  	)?></td>
  	<td style="font-size: 10px"><?php echo $post['Post']['post_user']?></td>
  	<td style="font-size: 10px"><?php echo date('Y-m-d H:i:s', $post['Post']['post_ptime'])?></td>
  	<td style="font-size: 10px"><?php echo count($post['Repost'])?></td>
  	<td style="font-size: 10px"><?php echo $post['Post']['repost_user']?></td>
  	<td style="font-size: 10px">
  		<?php if($post['Post']['repost_ptime']!=''):?>
  			<?php echo date('Y-m-d H:i:s', $post['Post']['repost_ptime'])?>
  		<?php endif?>
  	</td>
  </tr>
  <?php endforeach?>
</table>
<table>
  <tr>
  	<td colspan="6" style="font-size: 10px">
  		<?php echo $paginator->numbers();?>
  	</td>
  </tr>
</table>
<!-- <pre>
<?php print_r($data)?>
</pre> -->